package cn.iocoder.yudao.module.promotion.api.article;

import cn.hutool.core.bean.BeanUtil;
import cn.iocoder.yudao.module.promotion.api.article.dto.ArticleRespDto;
import cn.iocoder.yudao.module.promotion.dal.dataobject.article.ArticleDO;
import cn.iocoder.yudao.module.promotion.service.article.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

@Service
@Validated
public class ArticleApiImpl implements ArticleApi {

    @Autowired
    private ArticleService articleService;

    @Override
    public ArticleRespDto getByTitleOrSort(String title) {
        ArticleDO articleDO = articleService.getByTitleOrSort(title);
        if (articleDO != null) {
            return BeanUtil.toBean(articleDO, ArticleRespDto.class);
        }
        return null;
    }
}
